package main

import (
	"MaterialIdentification/svc"
	"github.com/gin-gonic/gin"
	"log/slog"
	"net/http"
)

// 保存日志
func Save(context *gin.Context) {
	l := Logs{}
	context.BindJSON(&l)

	//file, _ := context.FormFile("file")
	//fmt.Println("获取form成功：" + file.Filename)

	err := svc.Db.Create(&l).Error
	if err != nil {
		slog.Error("创建日志失败", "err", err)
		context.JSON(http.StatusOK, NewResp(1, "创建日志失败"))
		return
	}
	context.JSON(http.StatusOK, NewRespData("创建日志成功", l.Id))
}
